草庐IT

elasticsearch 聚合之 date_histogram 聚合

全部标签

ruby - Date::today 未定义?

为什么只有Date类的某些方法没有显式加载:require'date'线?例如:irb(main):002:0>Date.todayNoMethodError:undefinedmethod`today'forDate:Classfrom(irb):2from/Users/mwlang/.rvm/rubies/ruby-2.0.0-p0/bin/irb:16:in`'然后……irb(main):003:0>require'date'=>true导致...irb(main):004:0>Date.today=>#http://ruby-doc.org/stdlib-2.0/libdoc/

ruby - ruby Date.today 和 DateTime.now 的日期错误

我已经使用RVM安装了ruby​​-1.8.6-p383。系统ruby是1.9.1_p378-1我在使用ruby​​1.8时从Date.today和DateTime.now得到错误的日期。而Time.now是正确的:irb(main):002:0>DateTime.now.to_s=>"2126--1-10618T11:23:43+00:00"irb(main):004:0>Date.today.to_s=>"2126--1-10618"irb(main):005:0>Time.now=>ThuJan2811:55:27+00002010如果我切换到ruby​​1.9,一切都很好:ir

Ruby,从 Date.day_fraction_to_time 获取小时、秒和时间

我找到了这个方法here.start=DateTime.nowsleep15stop=DateTime.now#minutesputs((stop-start)*24*60).to_ihours,minutes,seconds,frac=Date.day_fraction_to_time(stop-start)我有以下错误:`':privatemethod`day_fraction_to_time'calledforDate:Class(NoMethodError)我检查了/usr/lib/ruby/1.9.1/date.rb并找到了它:defday_fraction_to_time(

sql - Arel 导致聚合无限循环

我在使用Arel聚契约(Contract)一查询中的2列时遇到了问题。当我运行它时,在railsdev-server崩溃之前,整个服务器会卡住一分钟。我怀疑是无限循环:)。也许我误解了Arel的整个概念,如果有人能看一下,我将不胜感激。这个查询的预期结果是这样的:[{:user_id=>1,:sum_account_charges=>300,:sum_paid_debts=>1000},...]a_account_charges=Table(:account_charges)a_paid_debts=Table(:paid_debts)a_participants=Table(:exp

ruby - 在 Elasticsearch 中计算地理距离

我在查询中使用geo_distancefilter和tire,它工作正常:search.filter:geo_distance,:distance=>"#{request.distance}km",:location=>"#{request.lat},#{request.lng}"我预计结果会以某种方式包括到我用于过滤器的地理位置的计算距离。有没有办法告诉elasticsearch在响应中包含它,这样我就不必在ruby​​中为每个结果计算它?==更新==我在谷歌群组中的foundtheanswer:search.sortdoby"_geo_distance","location"=>"

ruby-on-rails - 嵌套模型、表单和 date_select FormHelper 集成

我关注了RyanBatestutorial在嵌套模型上。我的几个嵌套模型都有与之关联的日期。在我的迁移中,它们实际上是“Date”类型。我尝试过的一些事情和遇到的问题date_select-可以处理表单对象前缀,但不能处理嵌套模型属性select_year-不适用于表单对象通过使用(Time.now.year-100)..(Time.now.year)并覆盖attr访问器start_date和end_date以获取选择中的值以形成日期和传递回来。仅适用于创建,不适用于更新将字段的数据类型更改为字符串并使用使用(Time.now.year-100)..(Time.now.year)填充年

ruby - 有没有办法计算 ElasticSearch 或 Tire 中索引的所有元素?

如果不必像这样进行搜索就可以对元素进行计数,那就太好了Obj.search("id:*").count这可能吗? 最佳答案 在ElasticSearch中,您可以使用计数API对所有元素进行计数curl-XGEThttp://localhost:9200/index/_count参见CountAPI他们网站上的文档。 关于ruby-有没有办法计算ElasticSearch或Tire中索引的所有元素?,我们在StackOverflow上找到一个类似的问题: ht

ruby-on-rails - 当我停止 rails server 时,我的 elasticsearch 索引会发生什么?

我对在Rails应用程序中使用Elasticsearch还很陌生,我正在使用耐嚼的gem来实现它。当我通过railss在开发模式下运行我的Rails应用程序时,我然后通过elasticsearch命令运行Elasticsearch并运行rakechewy:reset:all为我的数据创建索引。这样做一切正常,但如果我重新启动服务器,我必须再次运行rakechewy:reset:all命令以重建索引,否则我会收到错误消息。当我重新启动服务器时,索引会发生什么变化?服务器停止时是否销毁?我不是很熟悉Elasticsearch的功能,所以希望有人能对幕后发生的事情有所了解。

ruby-on-rails - Elasticsearch、轮胎与协会

运行:Ruby1.9.3p0(2011-10-30修订版33570)[x86_64-darwin11.2.0],Rails3.2.0我正在尝试通过跨协会的TIREgem进行Elasticsearch。出于某种原因,在TIRE导入或偶尔在View上执行rake时,我不断收到以下错误/错误:Daves-MacBook-Pro:outdoordave$rakeenvironmenttire:importCLASS=GearFORCE=true[IMPORT]Deletingindex'gears'[IMPORT]Creatingindex'gears'withmapping:{"gear":

org.elasticsearch.cluster.block.clusterblockexception: blocked by: [service_unavailable/1/state not

文章目录一.搭建集群时出现错误错误日志elasticsearch.logorg.elasticsearch.cluster.block.clusterblockexception:blockedby:[service_unavailable/1/statenotrecovered/initialized];原因:解决方案:一.搭建集群时出现错误错误日志elasticsearch.logorg.elasticsearch.cluster.block.clusterblockexception:blockedby:[service_unavailable/1/statenotrecovered/i